<?php
//<=============================Bean developpé par MOUMMID HAMZA >======================//
include_once('connectBD.php');
include_once('beans/tacheBean.php');
class tacheDao{
   public $listeTache= array();
   public function loadAllTache(){
     $req=connexion()->prepare("select * from tache");
     $req->execute();
     while($row = $req->fetch(PDO::FETCH_OBJ)) {
       $tache=new tacheBean();
       $tache->setIdTache(utf8_encode($row->idTache));
       $tache->setObjectif(utf8_encode($row->objectif));
       $tache->setDesignation(utf8_encode($row->designation));
       $tache->setDateDebut(utf8_encode($row->dateDebut));
       $listeTache[]=$tache;
         }
       return $listeTache;
  }

  public function loadIdTache($designation,$objectif){
     $reponse= connexion()->prepare('SELECT idTache FROM tache where designation like :designation and objectif like :objectif');
             $reponse->execute(array(':designation'=>$designation,':objectif'=>$objectif)) or die('erreur execution');
             $don3=$reponse->fetchAll();
             $idtache=$don3[0]['idTache'];

       return $idtache;
  }

   public function insertTache($tache){
     $objectif=$tache->getObjectif();   $designation=$tache->getDesignation();   $dateDebut=$tache->getDateDebut();
     $req=connexion()->exec("insert into tache(objectif,designation,dateDebut) values('$objectif','$designation','$dateDebut')"); 
   }

   public function insertNomadeTache($idtache,$idnomade){
    $req=connexion()->exec("insert into nomade_tache values($idnomade,$idtache)"); 
   }
}

?>